package com.ruoyi.canteen.controller.v1;

import com.ruoyi.canteen.domain.CanteenCpClass;
import com.ruoyi.canteen.service.ICanteenCpClassService;
import com.ruoyi.canteen.utils.BeanCopyUtils;
import com.ruoyi.canteen.vo.CanteenCpClassVo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author Ryan
 * @Date 2021/9/9 11:49
 * @Version 1.0
 */
@RestController
@RequestMapping("/v1/cpClass")
public class CpClassApiController extends BaseController {

    @Autowired
    private ICanteenCpClassService canteenCpClassService;


    /**
     * 查询菜品分类列表
     * @param mdId  门店ID
     */
    @GetMapping("/listByMdId/{mdId}")
    public TableDataInfo listByMdId(@PathVariable("mdId") Integer mdId)
    {
        List<CanteenCpClass> dbList = canteenCpClassService.selectCpClassListByMdId(mdId);
        List<CanteenCpClassVo> list = BeanCopyUtils.copyListProperties(dbList, CanteenCpClassVo::new);

        return getDataTable(list);
    }


}
